﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LP580.CG;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string act = Utils.RQ_str("act");
        if (act.ToLower() == "Out" && !IsPostBack)
        {
            clsUserAccount.doUserLogout();
        }
        if (!IsPostBack)
        {
            string strUser = Utils.RQ_str("u");
            tbxName.Text = strUser;
            if (strUser != "")
            {
                form2.DefaultFocus = "tbxPass";
            }
        }
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        DealLogin();
    }

    private void DealLogin()
    {
        string name = tbxName.Text.Replace("'", "");
        string pass = tbxPass.Text.Replace("'", "");

        clsUserAccount usr = clsUserAccount.ValidUser(name, pass);
        
        if (usr != null)
        {
            clsUserAccount.doUserLogin(usr);
            if (usr.MemberType == 1)
                Response.Redirect("User/UC1Welcome.aspx", true);
            else
                Response.Redirect("User/UC2Welcome.aspx", true);
        }
        else
        {
            Response.Write("<script>alert('用户名或密码错误！');history.go(-1);</script>");
            Response.End();
        }

    }
}